// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'; //使用vuexi18n的前提
import App from './App'
import router from './router'

Vue.use(Vuex); //必须放前面

// axios
import axios from "axios";
// axios.defaults.baseURL = '/api';
Vue.prototype.$ajax = axios;
//vue-router
import VueRouter from 'vue-router'
Vue.use(VueRouter)
//vue-resource
import VueResource from "vue-resource";
Vue.use(VueResource);

Vue.http.options.emulateJSON = true;
Vue.http.options.header = {
  'Content-Type': 'application/json; charset=UTF-8'
}

// 饿了么组件
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'

import {
  Toast
} from 'vux' //引入全局toast
Vue.component('toast', Toast)
import {
  XButton
} from 'vux' //引入全局button
Vue.component('x-button', XButton)
import {
  XDialog
} from 'vux' //引入全局遮罩对话框
Vue.component('x-dialog', XDialog)
import {
  XInput
} from 'vux' //引入全局input
Vue.component('x-input', XInput)

//懒加载
// import VueLazyload from 'vue-lazyload';
// Vue.use(VueLazyload, {
//   preLoad: 1.3, //预加载的宽高比
//   error: 'dist/error.png', //图片加载失败时使用的图片源
//   loading: require('../dist_/static/img/homepage-back.11f5db6.png'), //图片加载的路径
//   attempt: 1 //尝试加载图片数量次数
// })

// 视频播放
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css';

import VueTouch from "vue-touch";
Vue.use(VueTouch, {
  name: "v-touch"
});

import {
  Loadmore
} from "mint-ui";
Vue.component(Loadmore.name, Loadmore);
import {
  Spinner
} from "mint-ui";
Vue.component(Spinner.name, Spinner);

import {
  AlertPlugin,
  ToastPlugin,
  ConfirmPlugin
} from 'vux'

import {
  Tab,
  TabItem
} from 'vux'
Vue.component('tab', Tab)
Vue.component('tab-item', TabItem)

// 引入flexbox
import {
  Flexbox,
  FlexboxItem
} from 'vux'

Vue.component('flexbox', Flexbox)
Vue.component('flexbox-item', FlexboxItem)

//解决$t报错↓
import vuexI18n from 'vuex-i18n';
const store = new Vuex.Store({
  modules: {
    i18n: vuexI18n.store
  }
});
Vue.use(vuexI18n.plugin, store);
//解决$t报错↑



//引入filter
import * as filter from './common/filter.js';
// import * as date from './common/date.js';
Object.keys(filter).forEach(key => {
  Vue.filter(key, filter[key])
});

Vue.mixin({ //全局混入
  methods: {
    goback: function () { //返回首页
      this.$router.push({
        path: "/"
      });
    },
    gobackIDcard: function () { //返回至学生证主页
      this.$router.push({
        path: '/IDcard'
      })
    },
    goBackInfo: function () { //返回至基本信息页
      this.$router.push({
        path: '/IDcard/Info'
      })
    },

  }
})

Vue.use(MintUI)
Vue.use(ElementUI);
Vue.use(VideoPlayer);
// Vue.use(vux)
Vue.use(AlertPlugin)
Vue.use(ToastPlugin)
Vue.use(ConfirmPlugin)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>',
})
